<?php


/**
 * Notes:
 * PROJECT_NAME : ERP v1.8 重构erp
 * User: 夏鱼儿<397072174@qq.com>
 * Date: 2023/12/28
 * Time: 16:13
 */

namespace app\admin\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule = [
        'mobile'    => 'require|mobile',
        'name'      => 'require',
        'password'  => 'require|length:6,10',
        'real_name' => 'require',
        'page'      => 'require',
        "limit"     => "require",
        "status"    => "require|in:1,2",
        'id'        => 'require',
        "user_name" => "require|unique:user|length:6,20",
    ];

    protected $message = [
        'mobile.require'    => '手机号不能为空',
        'mobile.mobile'     => '手机号格式不正确',
        'name.require'      => '账号不能为空',
        'password.require'  => '密码不能为空',
        'password.length'   => '密码长度为6-10位',
        'real_name.require' => '真实姓名不能为空',
        'page.require'      => '页码不能为空',
        'limit.require'     => '每页条数不能为空',
        'status.require'    => '状态不能为空',
        'status.in'         => '状态值不正确',
        'id.require'        => 'id不能为空',
        "user_name.require" => '用户名不能为空',
        "user_name.unique"  => '用户名已存在',
        "user_name.length"  => '用户名长度为6-20位',
    ];

    protected $scene = [
        'list'       => ['page', 'limit'],
        'add'        => ['mobile', 'name', 'real_name', 'password','user_name'],
        "edit"       => ['id'],
        "editStatus" => ['id', "status"],
        "del"        => ['id'],
        'addStaff'   => ['mobile', 'name', 'role_id'],
    ];
}